package top.xiangqifu.springboot2_auth.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import top.xiangqifu.springboot2_auth.base.BasePageResult;
import top.xiangqifu.springboot2_auth.base.BaseResult;
import top.xiangqifu.springboot2_auth.dao.TbPortableMessageDAO;
import top.xiangqifu.springboot2_auth.entity.*;
import top.xiangqifu.springboot2_auth.service.MessageReplyService;
import top.xiangqifu.springboot2_auth.service.MessageService;
import top.xiangqifu.springboot2_auth.service.RelationshipService;
import top.xiangqifu.springboot2_auth.service.TbPortableMessageService;
import top.xiangqifu.springboot2_auth.vo.MessageVo;
import top.xiangqifu.springboot2_auth.vo.ReplyVo;
import top.xiangqifu.springboot2_auth.vo.ReportVo;
import top.xiangqifu.springboot2_auth.vo.ReportrVo;

import java.util.List;

@Api(tags = "留言板")
@RestController
@RequestMapping("/message")
public class MessageController {
    @Autowired
    private MessageService messageService;

    @Autowired
    private MessageReplyService messageReplyService;

    @Autowired
    private RelationshipService relationshipService;

    @Autowired
    private TbPortableMessageService tbPortableMessageService;

    @ApiOperation(value ="查询留言板信息",notes = "查询留言板信息功能接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "info",value = "发帖人、标题、内容模糊查询",dataTypeClass = String.class ,required = true),
            @ApiImplicitParam(name = "orderBy",value = "1：按照发帖时间降序(默认)，2：按照发帖时间升序，3：按照评论数降序，4：按照评论数升序，5：按照点赞数降序，6：按照点赞数升序，7：按照点击量降序，8：按照点击量升序",dataTypeClass = String.class ,required = true),
    })
    @GetMapping("/queryAll")
    public BasePageResult<List<TbUserMessage>> queryAll(@RequestBody MessageVo messageVo, PageBean page) throws Exception {
        return messageService.queryAll(messageVo,page);
    }

    @ApiOperation(value ="发布留言",notes = "发布留言功能接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "info",value = "内容",dataTypeClass = String.class ,required = true),
            @ApiImplicitParam(name = "title",value = "标题",dataTypeClass = String.class ,required = true),
    })
    @PostMapping("/add")
    public BaseResult add(@RequestBody TbUserMessage tbUserMessage) throws Exception {
        return messageService.add(tbUserMessage);
    }

    @ApiOperation(value ="查询详细留言板信息",notes = "查询详细留言板信息功能接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "umid",value = "留言编号",dataTypeClass = String.class ,required = true),
            @ApiImplicitParam(name = "orderBy",value = "1：按照发帖时间降序(默认)，2：按照发帖时间升序，3：按照评论数降序，4：按照评论数升序，5：按照点赞数降序，6：按照点赞数升序，7：按照点击量降序，8：按照点击量升序",dataTypeClass = String.class ,required = true),
    })
    @GetMapping("/queryReply")
    public BasePageResult<List<ReplyVo>> queryReply(@RequestBody ReplyVo replyVo, PageBean page) throws Exception {
        return messageReplyService.queryAll(replyVo,page);
    }

    @ApiOperation(value ="发布评论",notes = "发布评论功能接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "umid",value = "留言编号",dataTypeClass = String.class ,required = true),
            @ApiImplicitParam(name = "info",value = "评论内容",dataTypeClass = String.class ,required = true),
    })
    @PostMapping("/addReply")
    public BaseResult addReply(@RequestBody ReplyVo replyVo) throws Exception {
        return messageReplyService.add(replyVo);
    }

    @ApiOperation(value ="点赞留言",notes = "点赞留言功能接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "umid",value = "留言编号",dataTypeClass = String.class ,required = true),
    })
    @PostMapping("/like")
    public BaseResult likeadd(@RequestBody TbUserMessage message) throws Exception {
        return relationshipService.likeadd(message);
    }

    @ApiOperation(value ="点赞回帖",notes = "点赞回帖功能接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "umrid",value = "回帖编号",dataTypeClass = String.class ,required = true),
    })
    @PostMapping("/liker")
    public BaseResult likeradd(@RequestBody TbUserMessageReply reply) throws Exception {
        return relationshipService.likeradd(reply);
    }


    @ApiOperation(value ="举报留言",notes = "举报留言功能接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "umid",value = "留言编号",dataTypeClass = String.class ,required = true),
            @ApiImplicitParam(name = "info",value = "举报原因",dataTypeClass = String.class ,required = true),
    })
    @PostMapping("/report")
    public BaseResult reportadd(@RequestBody ReportVo reportVo) throws Exception {
        return relationshipService.reportadd(reportVo);
    }

    @ApiOperation(value ="举报回帖",notes = "举报回帖功能接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "umrid",value = "回帖编号",dataTypeClass = String.class ,required = true),
            @ApiImplicitParam(name = "info",value = "举报原因",dataTypeClass = String.class ,required = true),
    })
    @PostMapping("/reportr")
    public BaseResult reportradd(@RequestBody ReportrVo reportrVo) throws Exception {
        return relationshipService.reportradd(reportrVo);
    }

    @ApiOperation(value ="关注操作",notes = "关注操作功能接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "username",value = "用户账号",dataTypeClass = String.class ,required = true),
    })
    @PostMapping("/concernadd")
    public BaseResult concernadd(@RequestBody TbAuthUser user) throws Exception {
        return tbPortableMessageService.concernadd(user);
    }

    @ApiOperation(value ="查询关注我的用户列表",notes = "查询关注我的用户列表功能接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNumber",value = "分页页码",dataTypeClass = String.class ,required = true),
            @ApiImplicitParam(name = "pageSize",value = "分页大小",dataTypeClass = String.class ,required = true),
    })
    @GetMapping("/concernlist")
    public BaseResult queryList(PageBean page) throws Exception {
        return tbPortableMessageService.queryList(page);
    }

    @ApiOperation(value ="查询我关注的用户列表",notes = "查询我关注的用户列表列表功能接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNumber",value = "分页页码",dataTypeClass = String.class ,required = true),
            @ApiImplicitParam(name = "pageSize",value = "分页大小",dataTypeClass = String.class ,required = true),
    })
    @GetMapping("/concernnolist")
    public BaseResult querynoList(PageBean page) throws Exception {
        return tbPortableMessageService.querynoList(page);
    }

    @ApiOperation(value ="查询帖子点赞用户列表",notes = "查询帖子点赞用户列表功能接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "umid",value = "留言编号",dataTypeClass = Integer.class ,required = true),
            @ApiImplicitParam(name = "pageNumber",value = "分页页码",dataTypeClass = String.class ,required = true),
            @ApiImplicitParam(name = "pageSize",value = "分页大小",dataTypeClass = String.class ,required = true),
    })
    @GetMapping("/querymessgerlikelist")
    public BaseResult querylikeList(@RequestBody TbUserMessage message,PageBean page) throws Exception {
        return relationshipService.querylikeList(message,page);
    }


    @ApiOperation(value ="查询评论点赞用户列表",notes = "查询评论点赞用户列表功能接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "umrid",value = "评论编号",dataTypeClass = Integer.class ,required = true),
            @ApiImplicitParam(name = "pageNumber",value = "分页页码",dataTypeClass = String.class ,required = true),
            @ApiImplicitParam(name = "pageSize",value = "分页大小",dataTypeClass = String.class ,required = true),
    })
    @GetMapping("/querymessagereplyList")
    public BaseResult queryreplyList(@RequestBody TbUserMessageReply reply,PageBean page) throws Exception {
        return relationshipService.queryreplyList(reply,page);
    }

    @ApiOperation(value ="查询指定登录名用户的评论信息",notes = "查询指定登录名用户的评论信息功能接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "username",value = "登录名",dataTypeClass = Integer.class ,required = true),
            @ApiImplicitParam(name = "pageNumber",value = "分页页码",dataTypeClass = String.class ,required = true),
            @ApiImplicitParam(name = "pageSize",value = "分页大小",dataTypeClass = String.class ,required = true),
    })
    @GetMapping("/querymessageusernameList")
    public BaseResult queryReply(@RequestBody TbAuthUser user,PageBean page) throws Exception {
        return relationshipService.queryReply(user,page);
    }

    @ApiOperation(value ="查询关注指定用户的用户列表",notes = "查询关注指定用户的用户列表功能接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "username",value = "登录名",dataTypeClass = Integer.class ,required = true),
            @ApiImplicitParam(name = "pageNumber",value = "分页页码",dataTypeClass = String.class ,required = true),
            @ApiImplicitParam(name = "pageSize",value = "分页大小",dataTypeClass = String.class ,required = true),
    })
    @GetMapping("/queryuserList")
    public BaseResult queryuserList(@RequestBody TbAuthUser user,PageBean page) throws Exception {
        return tbPortableMessageService.queryuserList(user,page);
    }

    @ApiOperation(value ="查询指定用户关注的用户列表",notes = "查询指定用户关注的用户列表功能接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "username",value = "登录名",dataTypeClass = Integer.class ,required = true),
            @ApiImplicitParam(name = "pageNumber",value = "分页页码",dataTypeClass = String.class ,required = true),
            @ApiImplicitParam(name = "pageSize",value = "分页大小",dataTypeClass = String.class ,required = true),
    })
    @GetMapping("/queryuser")
    public BaseResult queryuser(@RequestBody TbAuthUser user,PageBean page) throws Exception {
        return tbPortableMessageService.queryuserList(user,page);
    }
}
